package com.zyicoding.myfactory.service.impl;

import com.zyicoding.myfactory.dao.FactoryLightMapper;
import com.zyicoding.myfactory.pojo.FactoryLight;
import com.zyicoding.myfactory.service.FactoryLightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class FactoryLightServiceImpl implements FactoryLightService {
    @Autowired
    FactoryLightMapper factoryLightMapper;

    @Override
    public FactoryLight selectLightStatus() {
        List<FactoryLight> list = factoryLightMapper.selectList(null);
        return list.get(0);
    }

    @Override
    public boolean changeLightStatus(String lightStatus) {
        FactoryLight factoryLight = new FactoryLight();
        factoryLight.setLightStatus(lightStatus);
        int result = factoryLightMapper.update(factoryLight, null);
        return result > 0;
    }
}
